import request from '@/utils/request'
import {CommonResponse} from "@/api/types/department";
import {BaseResponse} from "@/api/types/baseResponse";


interface ShopRequest {
    address?:string;
    childs?:ShopRequest[];
    id?:string;
    isarea?:string;
    latitude?:string;
    longitude?:string;
    manager?:{
        dept_id?:any;
        userid?:string;
        username?:string;
    }
    pid?:string;
    selfid?:string;
    shop_name?:string;
}


//查
export function getStoreInfo() {
    return request({
        url: '/account/shop',
        method: 'get',
    })
}

//查所有门店
export function getAllStoreInfo() {
    return request<BaseResponse<ShopRequest> ,BaseResponse<ShopRequest>>({
        url: '/shop/all',
        method: 'get',
    })
}


//增加
export const addStoreInfo = (data: any) => {
    return request({
        url: '/account/shop',
        method: 'post',
        data
    })
}

export const addAccountList = (params: object) => {
    const formData = new FormData()
    formData.append('username', params.username)
    formData.append('password', params.password)
    return request.post<CommonResponse>('/account/systeruser', formData)
}
//删除
export const deleteStoreInfo = (pid:number, data: any) => {
    return request({
        url: `/account/shop?pid=${pid}`,
        method: 'delete',
        data:{selfid:data}
    })
}
//改
export const editStoreInfo = (data: any) => {
    return request({
        url: '/account/shop',
        method: 'put',
        data
    })
}
